package com.lashou.chunshen.lashoutuangou.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AbsListView;
import android.widget.GridView;

import com.lashou.chunshen.lashoutuangou.R;
import com.lashou.chunshen.lashoutuangou.bean.HeaderViewBean;
import com.lashou.chunshen.lashoutuangou.bean.HomeCategory;
import com.lashou.chunshen.lashoutuangou.widget.MyGridView;
import com.lashou.chunshen.lashoutuangou.widget.banner.BannerPagerAdapter;

import java.util.List;

/**
 * Created by momo on 2016/9/6.
 */

public class FeileiBannerAdapter extends BannerPagerAdapter {
    int pageSize = 8;
    LayoutInflater inflater;
    List<HomeCategory.ResultsBean> data;
    Context context;


    public FeileiBannerAdapter(Context context, List<HomeCategory.ResultsBean> data) {
        super(context, data);
        this.data = data;
        this.context =context;
        size = (int) Math.ceil(data.size() * 1.0 / pageSize);
        inflater =LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return size;
    }

    @Override
    public View setView(int position) {
        MyGridView gv = new MyGridView(context);
        GridView.LayoutParams lParams = new GridView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
                AbsListView.LayoutParams.WRAP_CONTENT);
        gv.setPadding(60,20,0,0);
        gv.setLayoutParams(lParams);
        gv.setNumColumns(4);
        gv.setHorizontalSpacing(0);
        gv.setVerticalSpacing(15);
        gv.setAdapter(new GridViewAdapter(context,data,position));
        return gv;
    }
}
